import mysql.connector as connector
from mysql.connector import FieldType

import MySQLdb as mdb
import sys

try:
    con = mdb.connect('localhost', 'root', 'root123', 'test')

    cur = con.cursor()
    cur.execute('select  * from customer limit 1')
    print(cur.description)

except mdb.Error, e:
    print 'Error %d: %s' % (e.args[0], e.args[1])
    sys.exit(1)

finally:
    if con:
        con.close()




def main():
  conn = connector.connect(user='root', password='root123', database='test', use_unicode=False)
  cursor = conn.cursor()
  cursor.execute('select * from customer limit 1')
  values = cursor.fetchall()
  # print cursor.column_names
  print cursor.description
  # print(cursor.statement)

  for desc in cursor.description:
    colname = desc[0]
    coltype = desc[1]
    print("Column {} has type {}".format(
      colname, FieldType.get_info(coltype)))

  cursor.close()
  conn.close()
  # print(values)


